package com.github.fork.json;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author Jerry Liu
 * @since 2017/3/22
 */
public class IOUtils {

    /**
     * Read stream into string
     * @param in {@link InputStream}
     * @return string
     * @throws Exception
     */
    public static String read(InputStream in) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        StringBuilder builder = new StringBuilder();
        String line;
        while ((line = br.readLine()) != null) {
            builder.append(line);
        }
        return builder.toString();
    }
}
